package com.android.questions.ui.adapter;

import android.annotation.SuppressLint;
import android.view.View;

import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.content.ContextCompat;

import com.android.questions.R;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hx.currency.HXCurrencySDK;
import com.hx.currency.data.qa.model.QAInviteRecord;

import org.raphets.roundimageview.RoundImageView;

/**
 * FileName: InviteRecordAdapter
 * Author: admin
 * Date: 2021/11/4 15:07
 * Description:
 */
public class InviteRecordAdapter extends BaseQuickAdapter<QAInviteRecord, BaseViewHolder> {

    public InviteRecordAdapter() {
        super(R.layout.item_invite_record);
    }

    @Override
    protected int getDefItemViewType(int position) {
        return position;
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void convert(final BaseViewHolder baseViewHolder, QAInviteRecord item) {
        RoundImageView avatar = baseViewHolder.getView(R.id.item_avatar);
        AppCompatTextView itemName = baseViewHolder.getView(R.id.item_name);
        AppCompatTextView itemUid = baseViewHolder.getView(R.id.item_uid);
        AppCompatTextView itemDate = baseViewHolder.getView(R.id.item_date);
        AppCompatTextView itemState = baseViewHolder.getView(R.id.item_state);
        AppCompatTextView itemTips = baseViewHolder.getView(R.id.item_tips);

        Glide.with(avatar)
                .load(item.getHiu())
                .error(R.drawable.icon_user_default_header)
                .placeholder(R.drawable.icon_user_default_header)
                .into(avatar);

        itemName.setText(item.getNn());
        itemUid.setText("ID: " + HXCurrencySDK.getDecryptUserId(item.getUid()));
        itemDate.setText("邀请时间：" + item.getCt());

        int state = item.getHl();
        String tips;
        if (state == 1) {
            itemState.setTextColor(ContextCompat.getColor(getContext(), R.color.Color_FB5E27));
            tips = "有效用户";
            itemTips.setVisibility(View.GONE);
        } else {
            itemState.setTextColor(ContextCompat.getColor(getContext(), R.color.Color_44CB5E));
            tips = "待提现";
            itemTips.setVisibility(View.VISIBLE);
        }
        itemState.setText(tips);
    }
}